require.config({
    paths: {
        $: './zepto.min',
        Toast: './toast',
        xyIdCode: './idcode'
    }
});

require(['$', 'Toast', 'xyIdCode'], function ($, Toast, xyIdCode) {
    var myId = xyIdCode();
    myId.init("code");
    var loginButton = $("#login");
    loginButton.click(function () {
        var obj = {
            username: $("input[ name='username' ]").val(),
            password: $("input[ name='password' ]").val(),
            code: $("input[ name='code' ]").val()
        }
        if (!obj.username) {
            return Toast.toggle('请输入用户名', 2000);
        } else if (!obj.password) {
            return Toast.toggle('请输入密码', 2000);
        } else if (!obj.code) {
            return Toast.toggle('请输入验证码', 2000);
        } else if (!myId.validate(obj.code)) {
            return Toast.toggle('验证码有误', 2000);
        }
        //调登录接口
    });

    
    //点击返回按钮
    $("#goback").click(function () {
        window.history.go(-1);//返回上一页不刷新  
        //window.location.href = document.referrer;//返回上一页并刷新
    });


});